package org.kunlong.netix.util.log.stringmanager;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class LogStringMap {
	//private static Logger logger=Logger.getLogger(LogStringMap.class);
	private String packageName;
	private static final String LOG_STRING_FILE="log_string.properties";
	public String getPackageName() {
		return packageName;
	}

	public void setPackageName(String packageName) {
		this.packageName = packageName;
	}
	private Properties properties = new Properties();

	public void load()throws IOException {
		String filePath=translatePackageName(packageName)+LOG_STRING_FILE;
		InputStream inputStream=LogStringMap.class.getClassLoader().getResourceAsStream(filePath);
		//InputStream inputStream=LogStringMap.class.getResourceAsStream(filePath);
		properties.load(inputStream);
	}
	public String getString(String key){
		return (String)properties.get(key);
	}
	private String translatePackageName(String packageName){
		StringBuffer path=new StringBuffer("");
		if(packageName==null||packageName.equals("")){
			return path.toString();
		}
		String[] levels=packageName.split("\\.");
		for(String s:levels){
			path.append(s);
			path.append("/");
		}
		return path.toString();
	}
}
